home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 49
/
Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso
/
-serious-
/
misc
/
football
/
exec
/
changematchscore.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-11-29
|
11KB
|
479 lines
/* ***********************************************************************
CHANGE MATCH SCORE PROGRAM FOR FOOTBALL REXX SUITE
----------------------------------------------------
Copyright Mark Naughton 1999
Version Date History
--------------------------------------------------------------------------
1.0 260999 Created. Changes scores within the datafiles.
021099 Added code to allow user to select from a duplicate
match list.
031099 Changed format of matches written out if duplicated.
Changed date format.
**************************************************************************
Procedure
---------
1. Check files.
2. Read sflearn file into an array.
3. Read player stats into an array, if it exists.
4. Write new sflearn file, inserting new data.
5. Read sf file into an array.
6. Check for duplicates, if found, write to a file.
7. Using an external program, select the correct match.
8. Read response from written file.
9. Check sf array, overwriting the correct match.
10.Write new sf data to a file.
11.Display report.
************************************************************************** */
PARSE ARG league_stuff
version = 1
input_file = '.sflearn'
input2_file = '.sf'
input3_file = '.df'
details_file = 'RAM:Match.details'
separator = '*'
selines. = '???'
secount = 0
dets. = '???'
det_ct = 0
not_played = '__ __'
league_file = "Data/"league_file
dupmats. = '???'
if open(datafile,"Data/Football.locale",'r') then do
line = readln(datafile)
locdir = strip(line)
close(datafile)
end
else do
say
say "ERROR : (ChangeMatchScore)"
say
say "Cannot read 'Data/Football.locale' for the locale settings."
exit
end
locdir = locdir"Exec/ChangeMatchScore.data"
if open(datafile,"ENV:FootballRXPath",'r') then do
line = readln(datafile)
rxdir = strip(line)
close(datafile)
end
else
rxdir = "SYS:Rexxc/"
if exists(locdir) > 0 then do
address command rxdir'rx 'locdir
VarCount = getclip('VarCount')
do i = 1 to VarCount
interpret getclip('var.'i)
end
end
else do
say
say "ERROR : (ChangeMatchScore)"
say
say "Cannot find '"locdir"' to read locale settings."
exit
end
addlib('rexxsupport.library',0,-30,0)
parse var league_stuff league_file match
parse var match "*" tt1 "*" ss1 "*" ss2 "*" tt2 "*" mkrms
league_file = "Data/"strip(league_file)
unplay = 0
if strip(ss1) = "__" then unplay = 1
if exists(league_file || input_file) = 0 then do
say
say cms_error
say
say cms_one"'"league_file||input_file"'."
exit
end
if exists(league_file || input2_file) = 0 then do
say
say cms_error
say
say cms_one"'"league_file||input2_file"'."
exit
end
if exists(league_file || input3_file) = 0 then do
say
say cms_error
say
say cms_one"'"league_file || input3_file"'."
exit
end
if open(datafile,league_file || input3_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos("*LEAGUE_NAME=",line) > 0 then
parse var line "*LEAGUE_NAME=" league_name
end
close(datafile)
end
else do
say
say cms_error
say
say cms_two"'"league_file || input3_file"'"cms_three
exit
end
secount = 0
if open(datafile3,league_file || input_file,'r') then do
do while ~eof(datafile3)
line = readln(datafile3)
if line ~= "" then do
secount = secount + 1
selines.secount = strip(line)
end
end
close(datafile3)
end
else do
say
say cms_error
say
say cms_two"'"league_file || input_file"' "cms_three
exit
end
if exists(details_file) > 0 then do
parse value statef(details_file) with . fsize .
if fsize > 0 then do
if open(datafile4,details_file,'r') then do
do while ~eof(datafile4)
line = readln(datafile4)
if line ~= "" then do
det_ct = det_ct + 1
dets.det_ct = strip(line)
end
end
close(datafile4)
players = 1
end
else do
say
say cms_error
say
say cms_two"'"details_file"' "cms_three
exit
end
end
else
players = 0
end
else
players = 0
tt1 = strip(tt1)
tt2 = strip(tt2)
ss1 = strip(ss1)
ss2 = strip(ss2)
mkm = 0
mka = 0
if open(datafile3,league_file || input_file,'w') then do
do i=1 to secount
if pos(separator,selines.i) = 0 then
mkm = mkm + 1
if mkm > mkrms then
mka = 0
if mkm = mkrms & mka = 0 then do
mka = 1
stored_match = selines.i
if unplay = 0 then do
writeln(datafile3,left(tt1,30," ")" "right(ss1,2," ")" "right(ss2,2," ")" "tt2)
if players = 1 then do
do jk=1 to det_ct
if dets.jk ~= "" & dets.jk ~= "???" then
writeln(datafile3,strip(dets.jk))
end
end
end
end
if mka = 1 & selines.i == "*" then
writeln(datafile3,"*")
if mka = 0 & selines.i ~= "???" & selines.i ~= "" then
writeln(datafile3,selines.i)
end
close(datafile3)
end
else do
say
say cms_error
say
say cms_two"'"league_file || input_file"' "cms_four
end
secount = 0
if open(datafile3,league_file || input2_file,'r') then do
do while ~eof(datafile3)
line = readln(datafile3)
secount = secount + 1
selines.secount = strip(line)
end
close(datafile3)
end
else do
say
say cms_error
say
say cms_two"'"league_file || input2_file"' "cms_three
exit
end
ocrs = 0
numberm = "##NONE##"
do i=1 to secount
if pos("*Week",selines.i) > 0 then do
parse var selines.i "*Week" . numberm
numberm = "Week "strip(numberm)
end
if pos("*Date",selines.i) > 0 then do
parse var selines.i "*Date" . numbern
numberm = strip(DateFormat(numbern))
end
if numberm = "##NOT FOUND##" then do
say
say cms_error
say
say cms_t12
exit
end
if strip(stored_match) == strip(selines.i) then do
ocrs = ocrs + 1
if numberm = "##NONE##" then
numberm = ocrs
numberm = "("numberm")"
t1 = right(strip(substr(selines.i,1,30)),30,' ')
m1 = t1||substr(selines.i,31)
dupmats.ocrs = numberm" "strip(m1)
numberm = "##NONE##"
end
end
if ocrs > 1 then do
if open(datafile3,"RAM:DupMatches",'w') then do
do j=1 to ocrs
writeln(datafile3,dupmats.j)
end
close(datafile3)
end
else do
say
say cms_error
say
say cms_two"'RAM:DupMatches' "cms_four
exit
end
address command 'Exec/DupMatches'
address command 'c:Delete >NIL: RAM:DupMatches'
if open(datafile3,"RAM:DupMat.selection",'r') then do
do while ~eof(datafile3)
line = readln(datafile3)
if line ~= "" then
selmat = strip(line)
end
close(datafile3)
address command 'c:Delete >NIL: RAM:DupMat.selection'
end
else do
say
say cms_error
say
say cms_two"'RAM:DupMat.selection' "cms_three
exit
end
end
else
selmat = 1
ocrsg = 0
do i=1 to secount
if strip(stored_match) == strip(selines.i) then do
ocrsg = ocrsg + 1
if ocrsg = selmat then do
selines.i = left(tt1,30," ")" "right(ss1,2," ")" "right(ss2,2," ")" "tt2
leave
end
end
end
if open(datafile3,league_file || input2_file,'w') then do
do j=1 to secount
if j = secount then
writech(datafile3,selines.j)
else
writeln(datafile3,selines.j)
end
close(datafile3)
end
else do
say
say cms_error
say
say cms_two"'"league_file || input2_file"' "cms_four
exit
end
if exists(details_file) > 0 then
address command 'delete >NIL: 'details_file
say
say center(cms_five,78)
say "-------------------------------------------------------------------------------"
say
say
say cms_t1" : "strip(league_name)
say
say
say cms_t2
uline = ""
do k=1 to length(cms_t2)
uline = uline"-"
end
say uline
say
say stored_match
say
say
say cms_t3
uline = ""
do k=1 to length(cms_t3)
uline = uline"-"
end
say uline
say
say left(tt1,30," ")" "right(ss1,2," ")" "right(ss2,2," ")" "tt2
say
say
if unplay = 0 then
say cms_t4" : "cms_t5
else
say cms_t4" : "cms_t6
if players = 1 then do
say
say cms_t11
end
say
say
say "-------------------------------------------------------------------------------"
exit
/* Procedure --------------------------------------------------------- */
DateFormat :
parse arg datetoform
s_l = 0
dateall = datetoform
search_loc = strip(word(dateall,words(dateall)-1))
do mnls=1 to 12
if pos(word(months,mnls),search_loc) > 0 then do
s_l = 1
leave
end
end
if s_l = 0 then do
locale_cats = showdir("Locale/")
do search_locale=1 to words(locale_cats)
dfordir = "Locale/"word(locale_cats,search_locale)"/Football.locale_data"
if exists(dfordir) > 0 then do
address command rxdir'rx 'dfordir
VarCount = getclip('VarCount')
do i = 1 to VarCount
interpret getclip('var.'i)
end
end
dateall = datetoform
search_loc = strip(word(dateall,words(dateall)-1))
do mnls=1 to 12
if pos(word(months,mnls),search_loc) > 0 then do
s_l = 1
leave
end
end
if s_l = 1 then leave
end
end
if s_l > 0 then do
temp_dtal = dateall
parse var date_format "day" sp1 "number" sp2 "month" sp3 "year"
dateall = datetoform
do i=1 to 7
if pos(word(days,i),dateall) > 0 then do
lk = pos(word(days,i),dateall)
dateall = delstr(dateall,1,lk+length(word(days,i))+length(sp1)-1)
end
end
dateall = strip(dateall)
year = word(dateall,words(dateall))
mnth = strip(word(dateall,words(dateall)-1))
do lm=1 to length(mnth)
if datatype(substr(mnth,1,1),'m') ~= 1 then
mnth = delstr(mnth,1,1)
end
dateall = temp_dtal
day = word(dateall,2)
do lm=1 to length(day)-2
if datatype(substr(day,3,1),'n') ~= 1 then
day = delstr(day,3,1)
end
cv = 0
do i=1 to 12
if pos(word(months,i),mnth) > 0 then do
cv = i
leave
end
end
end
if s_l = 0 then return "##NOT FOUND##"
sd = year||right(cv,2,0)||right(day,2,0)
search_date = date('b',sd,'s')
return getweek(search_date)
/* Procedure --------------------------------------------------------- */
getweek:
parse arg days
dd = days - 722450
dd = date('n',dd,'i')
dd = delstr(dd,8,2)
parse var dd dy mn yy
dy = strip(dy)
mn = strip(mn)
yy = strip(yy)
parse var date_format "day" sp1 "number" sp2 "month" sp3 "year"
dd = dy||sp2||mn||sp3||yy
return dd
/* *********************************************************************** */